home *** CD-ROM | disk | FTP | other *** search
/ ADA Programming Guide / ADA Programming Guide.iso / ada_gwu / dbg.c < prev    next >
C/C++ Source or Header  |  1996-01-30  |  6KB  |  219 lines

  1. /*
  2.  * Copyright (C) 1985-1992  New York University
  3.  * 
  4.  * This file is part of the Ada/Ed-C system.  See the Ada/Ed README file for
  5.  * warranty (none) and distribution info and also the GNU General Public
  6.  * License for more details.
  7.  
  8.  */
  9.  
  10. #define GEN
  11.  
  12. /* dbg - debugger interface for adagen */
  13. #include "hdr.h"
  14. #include "vars.h"
  15. #include "segment.h"
  16. #include "gvars.h"
  17. #include "type.h"
  18. #include "dbgp.h"
  19.  
  20. static Segment zseg;
  21.  
  22. void zpds(Segment seg)                                            /*;zpds*/
  23. {
  24.     /* dump data segment, including initial data */
  25.  
  26.     int i, *data;
  27.  
  28.     printf("Segment %d x%x ", (int)seg, seg);
  29.     if (seg->seg_kind == SEGMENT_KIND_CODE) printf(" code");
  30.     else printf(" data");
  31.     printf(" size %d pos %d max_pos %d dim %d ext %d\n", seg->seg_size,
  32.       seg->seg_pos, seg->seg_maxpos, seg->seg_dim, seg->seg_extend);
  33.     if (seg->seg_kind == SEGMENT_KIND_CODE) return;
  34.     data = (int *) seg->seg_data;
  35.     for (i = 0; i < seg->seg_maxpos && i < 10; i++)
  36.         printf(" %d_%u", i, data[i]);
  37.     printf("\n");
  38. }
  39.  
  40. void zpttd()                                                    /*;zpttd*/
  41. {
  42.     if (zseg != (Segment) 0)
  43.         zptt(zseg);
  44. }
  45.  
  46. void zptt(Segment seg)                                            /*;zptt*/
  47. {
  48.     /* segment dump to terminal */
  49.  
  50.     struct tt_i_range  *tti;
  51.     int    *data;
  52.  
  53.     if (seg == (Segment) 0) {
  54.         printf("null segment\n");
  55.         return;
  56.     }
  57.     data = (int *) seg->seg_data;
  58.     tti = I_RANGE(data);
  59.     switch(tti->ttype) {
  60.  
  61.     case TT_I_RANGE:
  62.         printf("tt_i_range %d ilow %d ihigh %d\n", tti->object_size, 
  63.           tti->ilow,
  64.           tti->ihigh);
  65.         break;
  66.  
  67.     case TT_FL_RANGE: /* Floating point template */
  68.         printf("tt_fl_range %d %g fllow %g flhigh %g\n",
  69.            FL_RANGE(tti)->object_size,
  70.            FL_RANGE(tti)->fllow,
  71.            FL_RANGE(tti)->flhigh);
  72.         break;
  73.  
  74.     case TT_ENUM:
  75.         /* Enumeration(sub)type template
  76.          * For tt_enum case, literal values immediately follow, one for each
  77.          * case in the range. Each literal value consists of word giving length
  78.          * of value followed by that number of further words(with one character
  79.          * per word) giving the characters of the literal.
  80.          */
  81.  
  82.         printf("tt_enum%d elow %d ehigh %d \n",
  83.           tti->object_size,
  84.           E_RANGE(tti)->elow, E_RANGE(tti)->ehigh);
  85.  
  86.         break;
  87.  
  88.     case TT_E_RANGE:
  89.         printf("tt_enum%d elow %d ehigh %u ebase %u eoff %d\n",
  90.           tti->object_size,
  91.           E_RANGE(tti)->elow, E_RANGE(tti)->ehigh);
  92.         break;
  93.  
  94.     case TT_FX_RANGE:     /* Fixed point template */
  95.  
  96.         printf("tt_fx_range %d small_exp_2 %d small_exp_5\n",
  97.           tti->object_size,
  98.           FX_RANGE(tti)->small_exp_2,
  99.           FX_RANGE(tti)->small_exp_5);
  100.         printf(" %d fxlow %ld %ld fxhigh\n",
  101.           FX_RANGE(tti)->fxlow,
  102.           FX_RANGE(tti)->fxhigh);
  103.         break;
  104.  
  105.     case TT_ACCESS:     /* Access template */
  106.  
  107.         printf("tt_access %d master_task %d \n",
  108.           tti->object_size,
  109.           ACCESS(tti)->master_task);
  110.         break;
  111.  
  112.     case TT_U_ARRAY: /* Unconstrained or constrained array template */
  113.  
  114.         break;
  115.  
  116.     case TT_C_ARRAY: /* Unconstrained or constrained array template */
  117.  
  118.         printf("tt_u_array %d dim %d component_base %d component_offset %u \n",
  119.           tti->object_size,
  120.           ARRAY(tti)->component_base,
  121.           ARRAY(tti)->component_offset);
  122.         printf(" index1_base %u index1_offset %u \n",
  123.           ARRAY(tti)->component_base,
  124.           ARRAY(tti)->component_offset);
  125.         break;
  126.  
  127.     case TT_S_ARRAY:     /* Simple array template */
  128.  
  129.         printf("tt_s_array %d component_size %d index_size %d \n",
  130.           tti->object_size,
  131.           S_ARRAY(tti)->component_size,
  132.           S_ARRAY(tti)->index_size);
  133.         printf("salow %d sahigh %d\n",
  134.           S_ARRAY(tti)->salow,
  135.           S_ARRAY(tti)->sahigh);
  136.         break;
  137.  
  138.     case TT_D_ARRAY: /* Template for types depending on discriminants */
  139.  
  140.         printf("tt_d_array %d dbase %u doff %u nb_discr_d %d\n",
  141.           tti->object_size,
  142.           D_TYPE(tti)->dbase, D_TYPE(tti)->doff, D_TYPE(tti)->nb_discr_d);
  143.         break;
  144.  
  145.     case TT_RECORD:     /* Template for simple record */
  146.  
  147.  
  148.         printf("tt_record %d nb_field %d \n", tti->object_size, 
  149.           RECORD(tti)->nb_field);
  150.         break;
  151.  
  152.     case TT_U_RECORD:     /* Template for unconstrained record */
  153.  
  154.         printf("tt_u_record %d nb_field_u %d nb_discr_u %d nb_fixed_u \n",
  155.           tti->object_size, U_RECORD(tti)->nb_field_u,
  156.           U_RECORD(tti)->nb_discr_u,
  157.           U_RECORD(tti)->nb_fixed_u);
  158.         printf(" variant %d first_case %d\n",
  159.           U_RECORD(tti)->variant,
  160.           U_RECORD(tti)->first_case);
  161.         /* field table follows here */
  162.  
  163.         break;
  164.  
  165.     case TT_V_RECORD:
  166.         printf("tt_v_record %d nb_field_u %d nb_discr_u %d nb_fixed_u \n",
  167.           tti->object_size, U_RECORD(tti)->nb_field_u,
  168.           U_RECORD(tti)->nb_discr_u,
  169.           U_RECORD(tti)->nb_fixed_u);
  170.         printf(" variant %d first_case %d\n",
  171.           U_RECORD(tti)->variant,
  172.           U_RECORD(tti)->first_case);
  173.         break;
  174.  
  175.     case TT_C_RECORD:     /* Template for constrained record */
  176.  
  177.         printf("tt_c_record %d cbase %d coff %d nb_discr_c \n",
  178.           C_RECORD(tti)->object_size,
  179.           C_RECORD(tti)->cbase,
  180.           C_RECORD(tti)->coff,
  181.           C_RECORD(tti)->nb_discr_c);
  182.         break;
  183.  
  184.     case TT_D_RECORD: /* Template for types depending on discriminants */
  185.  
  186.         printf("tt_d_record %d dbase %d doff %d nb_discr_d \n",
  187.           D_TYPE(tti)->object_size,
  188.           D_TYPE(tti)->dbase,
  189.           D_TYPE(tti)->doff,
  190.           D_TYPE(tti)->nb_discr_d);
  191.         /* entries for discriminants follow here */
  192.  
  193.         break;
  194.  
  195.     case TT_TASK:         /* Task type template */
  196.  
  197.         printf("tt_task %d priority %u body_base %u body_off %u \n",
  198.           tti->object_size,
  199.           TASK(tti)->priority,
  200.           TASK(tti)->body_base,
  201.           TASK(tti)->body_off);
  202.         printf("nb_entries %d nb_families %u\n",
  203.           TASK(tti)->nb_entries,
  204.           TASK(tti)->nb_families);
  205.         /* entry table follows here */
  206.         break;
  207.  
  208.     case TT_SUBPROG:     /* Subprogram template */
  209.         printf("tt_subprog %d cs %u relay_slot %u\n",
  210.           tti->object_size,
  211.           SUBPROG(tti)->cs,
  212.           SUBPROG(tti)->relay_slot);
  213.         break;
  214.  
  215.     default:
  216.         printf("unknown kind %d\n", tti->ttype);
  217.     }
  218. }
  219.